home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 4 / Precision Software Applications Silver Collection Volume 4 (1993).iso / stats / chadyn.exe / YINTRPT.C < prev    next >
Text File  |  1988-12-11  |  35KB  |  1,356 lines

  1. /********************************* YINTRPT.C *********************************/
  2. /***********************(C) 1986,7,8 by JAMES A. YORKE **********************/
  3. /*********************   Routines in YINTRPT.C  ***********************
  4. Interrupt()    Hitting a key while the map is being iterated will summon
  5.             intervention
  6. PrintJumpSign()
  7. SetAndSave(new,current,old)  saves *current in *old and if new is set, it 
  8.         sets *current = *new; it then sets *new = *current /
  9. SwitchD(A,B)
  10. SetCross(crossnumber) in YCROSS.C
  11. CrossPosition()       in YCROSS.C
  12. turnoff()             in YCROSS.C
  13. SwitchI(A,B)
  14. start()  used in printing the vector lyapsum  /
  15. ResetScrnLineAtTop()
  16. plotImages()    This routine initializes y = y1 and plots the several images 
  17.         of that point; but we don't plot the images each time an 
  18.         arrow key is hit if we are supposed to be plotting circles and 
  19.         their images; in other words, wait until the cursor stops 
  20.         moving; /
  21. ***********************************************************************/
  22.  
  23.  
  24.  
  25.  
  26. #include "yinclud.h"
  27.  
  28. #ifndef MAINFRAME /* wipes out whole file */
  29. #ifdef MS
  30. #include <bios.h>        /* for _bios_keybrd for checking NUM LOCK */
  31. static int      palette = 0;
  32. #endif                /* MS */
  33.  
  34. #ifndef X11
  35. static long     count;
  36. #endif
  37.  /* The values of the following 2 are largely irrelevant */
  38. #define RET 454 
  39. #define CONT 2639
  40. static int      arrowCounts;
  41. static unsigned shift;
  42. static  UvsSflag = 0;        /* if 'u' was called more recently than
  43.                    's',this is 1 */
  44. static int      overflow;    /* for 'O' circle warning that we have left box
  45.                    */
  46. static int      kk = 0;        /* this is static for purposes of using ALT_O
  47.                    for drawing a cross only ALT_O is not in use
  48.                    */
  49.  
  50. /* Hitting a key while the map is being iterated will summon
  51.  * intervention. Cross 0 is at position of y[] when cycle = 1 or 2 and is
  52.  * turned off if cycle = 0; Cross 1 is initially off but is at position
  53.  * y1[] if y1 has been reset; if both are set and overlap, they annihilate
  54.  * each other where they overlap.
  55.  */
  56. #ifdef X11
  57.  
  58. /* INTERRUPT - X11 version to avoid infinite loops when single stepping
  59.  * and plotting one iterate as the 'p' key is pressed.
  60.  */
  61. Interrupt() 
  62. {
  63.     int    key;
  64.     int    retval;
  65.     static char    *pausemsg = "PAUSE at dot #%ld; \
  66. 'Esc' terminates pause mode; hit 'p' again for one dot\n";
  67.     static char    *complaint = "NOT AN ALLOWABLE INTERRUPT\n";
  68.  
  69.     if(cycle == 0)  {        / usual state unless single stepping */
  70.         while((key = awaitkey(1)) != 0 
  71.            && (retval = carryOutInt(key)) != RET)
  72.             if(retval == NO)
  73.                 PRINT complaint);
  74.         arrowCounts = 0;
  75.         return;
  76.     } else if(cycle == 1)  {
  77.         if(level < PROCESS)
  78.             PRINT "INTERRUPT MODE: hit any interrupt key; hit 'p' to exit mode    \n");
  79.         else  {
  80.             plotSomething(0);
  81.             if(IsCross0Set)
  82.                 SetCross(BIGCROSS);
  83.             scr_rowcol(0, 0);
  84.             erase_line();
  85.             PRINT pausemsg, dot);
  86.         }
  87.     }
  88.     else if(cycle == 2)
  89.         overflow = YES;
  90.  
  91.     /* Here we are in single step mode.  Wait for a key to be pressed
  92.      * and process the interrupt.  The external variable CYCLE can be
  93.      * altered in carryOutInt.
  94.      */
  95.     key = awaitkey(0);
  96.     while(key != 0 && cycle > 0) {
  97.         retval = carryOutInt(key);
  98.         if(retval == NO)
  99.             PRINT "NOT AN ALLOWABLE INTERRUPT\n");
  100.         else if(retval == RET)
  101.             break;
  102.         if(printer > 0 && prnFlag == OFF)
  103.             PRINT pausemsg, dot);
  104.         key = awaitkey(0);
  105.     }
  106.     arrowCounts = 0;
  107.     return;
  108. }
  109. #else
  110. Interrupt() 
  111. {
  112.     double  startTime;
  113.     int     ret = YES,
  114.             carryOutInt();
  115.     int     keycheck();    /* now local */
  116.  
  117.  /* notice cycle may still be 1 from a previous pass thru Interrupt. That
  118.     occurs only when the keycheck() below yields  'o' or 'p'. The only way to
  119.     leave this loop is via a return */
  120.  /* cycle is either 0 or 1 or 2, and >= 1 if the program is single stepping and
  121.     = 2 if this routine was called by plot */
  122.  
  123.     arrowCounts = count = 0;/*   certain printing is only done AFTER the
  124.                    first pass through the loop if cycle > 0;
  125.                    i.e., if count > 0 */
  126.     if(cycle > 0) {
  127.         if(cycle == 1 && level >= PROCESS) {
  128.             plotSomething(0);
  129.                 /* 0 means plot but do not iterate map */
  130.             if(IsCross0Set == NO)
  131.                 SetCross(BIGCROSS);
  132.             scr_rowcol(0, 0);
  133.             erase_line();
  134.             if(printer > 0)
  135.                 PRINT
  136. "PAUSE at dot #%ld; 'Esc' terminates pause mode; hit 'p' again for one dot\n"
  137.                     ,dot);
  138.         }
  139.         else
  140.             if(cycle == 1 && level < PROCESS) {
  141.                 PRINT
  142.     "INTERRUPT MODE: hit any interrupt key; hit 'p' to exit mode    \n");
  143.             }
  144.             else
  145.                 overflow = YES;/* cycle = 2 warning for 'O' */
  146.     }
  147.  
  148.     for(;;) {
  149.         if((kk = keycheck()) == 0) {
  150.             if(count == 0 && cycle == 0) {
  151.                 return;
  152.                 /* this statement assures as little time as
  153.                    possible will be spent in this routine in
  154.                    this default case */
  155.             }
  156.             if(count > 0) {
  157.                 startTime = timeofday();
  158. #define SEC    0.55  
  159.             /* SEC is how long(in seconds) my keyboard waits, when
  160.                you hold a key down, before telling the computor
  161.                that it has been held down and has not been released
  162.                */
  163.                 while((kk = keycheck()) == 0
  164.                         && timeofday() - startTime < SEC);
  165.                 /* only look for a non-zero kk and keep looking
  166.                    for SEC seconds */
  167.             }
  168.             if(kk == 0 && cycle == 0) {
  169.                 /* reach here if count > 0 */
  170.                 arrowCounts = 0;
  171.                 /* reach here if in pause mode and no key has
  172.                    been hit recently */
  173.                 return;
  174.             }
  175.             if(kk == 0 && cycle > 0) {
  176.                 scr_rowcol(0, 0);
  177.                 if(printer > 0 && prnFlag == OFF)
  178.                     PRINT
  179.                         "PAUSE at dot #%ld; 'Esc' terminates pause mode; hit 'p' again for one dot\n"
  180.                         ,dot);
  181.             }
  182.  
  183.         }
  184.  
  185.         count++;    /*   certain printing is only done AFTER the
  186.                    first pass through the loop if cycle > 0;
  187.                    i.e., if count > 0 */
  188.         if(kk != 0) {
  189.             ret = carryOutInt(kk);
  190.             if(ret == RET)
  191.                 return;
  192.             if(ret == NO)
  193.                 PRINT "NOT AN ALLOWABLE INTERRUPT  \n");
  194.         }
  195.         else
  196.             arrowCounts = 0;
  197.                 /* reach here if in pause mode and no key has
  198.                    been hit recently */
  199.  
  200.     /* if cycle is 1 or 2 the cross0 should be set and will be set unless
  201.        it was turned off because of F1 ...F4 of F10 */
  202.  
  203.  
  204.  
  205.     }            /* end of for(;;) loop */
  206. }
  207. #endif    /*ifdef X11 else */
  208. PrintJumpSign() {
  209.     if(SignIsOn == 1)
  210.         return;
  211.     SignIsOn = 1;
  212.     if(printer > 0) {
  213.         scr_rowcol(21, 0);
  214.         erase_line();
  215.         PRINT
  216.             "ON NUMERIC KEYPAD: 1 halves jump size for small cross position, 3 doubles it"
  217.             );
  218.     }
  219.     scr_rowcol(0, 0);
  220. }
  221.  
  222.  
  223. SetAndSave(new, current, old)    /*  saves *current in *old and if new is set,
  224.                    it sets *current = *new; it then sets *new =
  225.                    *current */
  226. double *new,
  227.        *current,
  228.        *old;
  229. {
  230.     *old = *current;
  231.     if(*new != -9999.)
  232.         *current = *new;
  233.     *new = *current;
  234. }
  235.  
  236. SwitchD(A, B)
  237. double *A,
  238.        *B;
  239. {
  240.     double  temp;
  241.     temp = *A;
  242.     *A = *B;
  243.     *B = temp;
  244. }
  245.  
  246. SwitchI(A, B)
  247. int    *A,
  248.        *B;
  249. {
  250.     int     temp;
  251.     temp = *A;
  252.     *A = *B;
  253.     *B = temp;
  254. }
  255.  
  256.  
  257. ResetScrnLineAtTop() {
  258.     scr_rowcol(0, 0);    /* move cursor to upper left, a routine in
  259.                    desmet's pcio.a */
  260.     erase_line();
  261.     if(cycle == 1) {
  262.         PRINT "\n");    /* skip line */
  263.         erase_line();
  264.     }
  265. }
  266.  
  267.  
  268. plotImages() {            /* This routine initializes y = y1 and plots
  269.                    the several images of that point; but we
  270.                    don't plot the images each time an arrow key
  271.                    is hit if we are supposed to be plotting
  272.                    circles and their images; in other words,
  273.                    wait until the cursor stops moving; */
  274.     int     i;
  275.  
  276.     if(images == 0)
  277.         return;
  278.  
  279.     stoplines();         /* for stopping drawing connected lines */
  280.     start();        /* sets dot = 0 and lyap exponents are
  281.                    restarted */
  282.     setequal(0, 1, eqn1);
  283.  
  284.     if(taskFlag != PLOTCIRC) {
  285.         turnoff(BIGCROSS);
  286.         for(i = 0; i < images; i++)
  287.             plotSomething(1);/* plots a point and iterates */
  288.         plotSomething(0);/* plots a point and does not iterate */
  289.         plotSomething(0);
  290.                 /* otherwise the last point doesnt get plotted
  291.                    on CRT when images > 0 */
  292.         SetCross(SMALLCROSS);
  293.         if(cycle > 0) {
  294.             SetCross(BIGCROSS);
  295.         /*     SetCross(BIGCROSS); */
  296.         }
  297.     }
  298. }
  299.  
  300.  
  301.  
  302. int     isNumLockOn() {
  303. #ifdef MS
  304.             shift = _bios_keybrd(_KEYBRD_SHIFTSTATUS);
  305.                 /* for checking NUM LOCK */
  306.     if((shift & mask[7 - 5]) != 0)
  307.         return(YES);
  308. #endif    /* MS */
  309.     return(NO);
  310. }
  311.  
  312.  
  313. int     carryOutInt(kk)
  314. int(kk);
  315. {
  316.     char    CodeName[MAXCHAR+1];
  317.     FILE * saveptr;
  318.     int     checkPrinter();/* make sure printer is on line */
  319.     int     strcmp();    /* to see if we have the henon map */
  320.     int     keycheck();    /* now local */
  321.     int     printerStatus();
  322.     int     random(), set_box();
  323.     int     digit,
  324.             i,
  325.             coord,
  326.             oldTaskFlag,
  327.             isNumLockOn();
  328.     int     ss;        /* temporary ScrnSec */
  329.     int     temp,
  330.             temp1,
  331.             saveTaskFlag;
  332.     int     oldTicFlag;
  333.     double  doubleDot;
  334.     double  old_rho;
  335.     int     saveIter = iter,
  336.             saveGoodIterate = goodIterate,
  337.             saveOldGoodIt = oldGoodIt;
  338.     double  saveFrac = frac,
  339.             saveAdd = add,
  340.             saveLength = length;
  341.  
  342.     if(isNumLockOn() == YES) {
  343.         scr_rowcol(3, 0);
  344.         erase_line();
  345.         scr_rowcol(3, 0);
  346.         PRINT
  347.             "NumLock is on; hit NumLock key and thereby turn it off;\n");
  348.         return(RET);
  349.     }
  350.  
  351.     if(kk == LEFT) {    /* 75 is code for "left" key */
  352.         coord = eqn0 + ssX_coord[ScrnSec];
  353.         y[coord] -= ((arrowCounts + 3) / 3) *
  354.             screen_fraction *(X_upper - X_lower);
  355.         SetCross(SMALLCROSS);
  356.         PrintJumpSign();
  357.         plotImages();
  358.         arrowCounts++;
  359.         return(CONT);    /* this allows the program to check for another
  360.                    arrow command even though we are not in
  361.                    single stepping mode */
  362.     }
  363.     if(kk == RIGHT) {    /* code for right key */
  364.         coord = eqn0 + ssX_coord[ScrnSec];
  365.         y[coord] += ((arrowCounts + 3) / 3) *
  366.             screen_fraction *(X_upper - X_lower);
  367.         SetCross(SMALLCROSS);
  368.         PrintJumpSign();
  369.         plotImages();
  370.         arrowCounts++;
  371.         return(CONT);    /* this allows the program to check for another
  372.                    arrow command even though we are not in
  373.                    single stepping mode */
  374.     }
  375.     if(kk == DOWN) {    /* 80 is code for down key */
  376.         coord = eqn0 + ssY_coord[ScrnSec];
  377.         y[coord] -= ((arrowCounts + 3) / 3) *
  378.             screen_fraction *(Y_upper - Y_lower);
  379.         SetCross(SMALLCROSS);
  380.         PrintJumpSign();
  381.         plotImages();
  382.         arrowCounts++;
  383.         return(YES);    /* this allows the program to check for another
  384.                    arrow command even though we are not in
  385.                    single stepping mode */
  386.     }
  387.     if(kk == UP) {        /* 72 is IBM code for  up key */
  388.         coord = eqn0 + ssY_coord[ScrnSec];
  389.         y[coord] += ((arrowCounts + 3) / 3) *
  390.             screen_fraction *(Y_upper - Y_lower);
  391.         SetCross(SMALLCROSS);
  392.         PrintJumpSign();
  393.         plotImages();
  394.         arrowCounts++;
  395.         return(CONT);    /* this allows the program to check for another
  396.                    arrow command even though we are not in
  397.                    single stepping mode */
  398.     }
  399.  
  400.     scr_rowcol(0, 0);    /* move cursor to upper left, a routine in
  401.                    desmet's pcio.a */
  402.  
  403.     if(cycle == 1) {    /* do not plot if cycle == 2 */
  404.         plotSomething(0);/* 0 means plot but do not iterate map */
  405.         if(IsCross0Set == NO)
  406.             SetCross(BIGCROSS);
  407.  
  408.     }
  409.     if(kk == 'o' || kk == 'p') {/* 'o' is archaic usage */
  410.         if(cycle == 0) {
  411.             SetCross(SMALLCROSS);
  412.             SetCross(BIGCROSS);
  413.         }
  414.         cycle = 1;
  415.         return(RET);
  416.     }
  417.     SetCross(SMALLCROSS);
  418.  /* this is after kk == 'p';  if trying to iterate quickly, there is no need to
  419.     set cross 1; if we do it slowly, there will be interspersed lots of cases
  420.     of kk = 0 and then it will get set */
  421.  
  422.     if(num_lyap > 0 && printer > 0)
  423.         PRINT "\n");
  424.     if(ODEcheck > 0 && printer > 0)
  425.         PRINT "\n");
  426.  
  427.     if(kk == ESC) {
  428.         turnoff(BIGCROSS);
  429.         ResetScrnLineAtTop();
  430.         cycle = 0;
  431.         return(RET);
  432.     }
  433.  
  434.     if(kk == '#' || kk == ':') {
  435.         saveTaskFlag = taskFlag;
  436.         saveptr = input;/* in case input is from a file */
  437.         input = StInput;
  438.  
  439.         scr_rowcol(0, 0);
  440.         definitely_erase_line();
  441.  
  442.         if(printer > 0) {
  443.             ret_erase_line(4);
  444.             PRINT
  445.                 "#############################################################################"
  446.                 );
  447.             scr_rowcol(0, 0);/* leave line 0 blank now */
  448.             PRINT
  449.                 "\nEach Interrupt ':' permits you only ONE command(= one menu item). \n");
  450.             PRINT
  451.                 "Hit Return key now if you now want to return to plotting. \n");
  452.             PRINT
  453.                 "Enter  Menu item(MM = MainMenu; * plus code gives help):\n");
  454.         }
  455.         else {
  456.             PRINT "\n");
  457.             definitely_erase_line();
  458.         }
  459.         scr_rowcol(0, 0);
  460.         definitely_erase_line();
  461.         PRINT "ENTER COMMAND: ");
  462.  
  463.         GetCommandAndImplement(CodeName);
  464.  
  465.         if(printer > 0) {
  466.             scr_rowcol(0, 0);
  467.             erase_line();
  468.             ret_erase_line(1);
  469.             scr_rowcol(0, 0);
  470.             PRINT
  471.                 "####################### Hit r to refresh the screen. ########################"
  472.                 );
  473.         }
  474.         else {
  475.             scr_rowcol(0, 0);
  476.             definitely_erase_line();
  477.             PRINT "\n");
  478.             definitely_erase_line();
  479.             scr_rowcol(0, 0);
  480.         }
  481.         input = saveptr;/* return input to previous setting */
  482.         taskFlag = saveTaskFlag;
  483.     /* the following are for YU.C */
  484.         frac = saveFrac;
  485.         add = saveAdd;
  486.         length = saveLength;
  487.         iter = saveIter;
  488.         goodIterate = saveGoodIterate;
  489.         oldGoodIt = saveOldGoodIt;
  490.         SetCross(SMALLCROSS);
  491.     /* this is needed if color has been changed */
  492.         return(YES);
  493.     }
  494.  
  495.     if(kk == ' ') {    /* routine should end & go to menu */
  496.         taskFlag = -1;    /* this means that when plotsomething() is
  497.                    called, we do not plot a dot */
  498.         SignIsOn = NO;    /* sign about jump size */
  499.         if(level >= PROCESS)
  500.             level--;
  501.         if(level < PROCESS)
  502.             cycle = NO;
  503.         else
  504.             if(printer > 0) {
  505.                 scr_rowcol(5, 0);
  506.                 erase_line();
  507.                 if(cycle > 0)
  508.                     PRINT "paused. ");
  509.                 PRINT "level = menu+%d            \n", level - 2);
  510.             }
  511.         scr_rowcol(0, 0);
  512.         return(RET);
  513.     }
  514.  
  515.     if(kk == End) {    /* 79 is code for end key */
  516.         screen_fraction = screen_fraction / 2.;
  517.         if(printer > 0) {
  518.             scr_rowcol(23, 0);
  519.             erase_line();
  520.             PRINT
  521.                 "arrow keys shift and reinitialize y1 by this fraction of the screen:%3.3le \r"
  522.                 ,screen_fraction);
  523.         }
  524.         ResetScrnLineAtTop();
  525.         return(YES);
  526.     }
  527.  
  528.     if(kk == PgDn) {    /* 81 is code for  Pg Dn  key */
  529.         screen_fraction = screen_fraction * 2.;
  530.         if(printer > 0) {
  531.             scr_rowcol(23, 0);
  532.             erase_line();
  533.             PRINT
  534.                 "arrow keys shift and reinitialize y1 by this fraction of the screen:%3.3le \r"
  535.                 ,screen_fraction);
  536.         }
  537.         ResetScrnLineAtTop();
  538.         return(YES);
  539.     }
  540.     if(kk == Home) {    /* 71 is code for home key */
  541.         rho_step = rho_step / 2.;
  542.         if(printer > 0) {
  543.             erase_line();
  544.             PRINT "rho increment = %lf, rho=%lf            \r",
  545.                 rho_step, rho);
  546.         }
  547.         return(YES);
  548.     }
  549.     if(kk == PgUp) {    /* 73 is code for  Pg Up  key */
  550.         rho_step = rho_step * 2.;
  551.         if(printer > 0) {
  552.             erase_line();
  553.             PRINT "change in rho = %lf, rho=%lf          \r",
  554.                 rho_step, rho);
  555.         }
  556.         return(YES);
  557.     }
  558.     if(kk == '+') {    /* to declare picture finished */
  559.         start();    /* sets dot = 0 and lyap exponents are
  560.                    restarted */
  561.         old_rho = rho;
  562.         *pIncrement += rho_step;
  563.         if(pIncrement == &rho && rho_final == old_rho)
  564.             rho_final = rho;
  565.         ResetScrnLineAtTop();
  566.         if(printer > 0)
  567.             PRINT
  568.                 "new value=%lf;          ON NUMERIC KEYPAD:7 halves rhostep,9 doubles it\n"
  569.                 ,*pIncrement);
  570.         return(YES);
  571.     }
  572.     if(kk == '-') {
  573.         start();    /* sets dot = 0 and lyap exponents are
  574.                    restarted */
  575.         old_rho = rho;
  576.         *pIncrement -= rho_step;
  577.         if(pIncrement == &rho && rho_final == old_rho)
  578.             rho_final = rho;
  579.         ResetScrnLineAtTop();
  580.         if(printer > 0)
  581.             PRINT
  582.                 "new value=%lf;          ON NUMERIC KEYPAD:7 halves rhostep,9 doubles it\n"
  583.                 ,*pIncrement);
  584.         return(YES);
  585.     }
  586.  
  587.     if(kk == '*') {
  588.         ResetScrnLineAtTop();
  589.         OptionsHelp();    /* in yopmenus.c */
  590.         return(YES);
  591.     }
  592.  
  593.     if(kk == '?') {
  594.         ResetScrnLineAtTop();
  595.         getText("yintrpt.doc", "keys");
  596.         erase_line();
  597.         PRINT
  598.             "==== Hit r to refresh the screen =========== Hit * plus key for more help===="
  599.             );
  600.         return(YES);
  601.     }
  602.  
  603.     if((kk >= '0') &&(kk <= '3')) {
  604.         printer = kk - '0';
  605.         return(YES);
  606.     }
  607.  
  608.     if((kk >= '4') &&(kk <= '6')) {
  609.                 /* Setting kk >= '3' causes lyap exponents and
  610.                    ordinary differential equation error data to
  611.                    be printed out as it is computed Setting '4'
  612.                    causes a point data to be printed on first
  613.                    call of iterate_map() which then resets
  614.                    printer to 2. Setting kk = '5' causes
  615.                    position vector to be printed EVERY TIME a
  616.                    point is ITERATED which can be more frequent
  617.                    than plotting. Used in iterate_map. */
  618.         if(checkPrinter() == YES) {
  619.                 /* in YPLOT.C; means printer is on line and
  620.                    ready to print */
  621.             printer = kk - '0';
  622.             print_text(StPrint);
  623.                 /* text goes to printer before stream of data
  624.                    if "printer" >= 1 */
  625.             printer = kk - '0';
  626.         }
  627.         return(YES);
  628.     }
  629.  
  630.     if(kk == 'a') {
  631.         cycle = 0;
  632.         dot = dots;
  633.         return(YES);
  634.     }
  635.     if(kk == 'b') {    /* toggle for drawing a box using scale,    */
  636.         draw_box();
  637.         return(YES);
  638.     }
  639.     if(kk == 'B') {    /* toggle for drawing a box using scale,    */
  640.         ss = ScrnSec;
  641.         X_lower = X_low = x_new_low = X_Lo[ss];
  642.         Y_lower = Y_low = y_new_low = Y_Lo[ss];
  643.         X_upper = X_upp = x_new_upp = X_Up[ss];
  644.         Y_upper = Y_upp = y_new_upp = Y_Up[ss];
  645.         PrintBoxCoordinates();
  646.                 /* if printer > 1; prints  coordinates of
  647.                    screen */
  648.         return(YES);
  649.     }
  650.  
  651.     if(kk == 'c') {    /* to clear screen and p[][], hit C; to clear
  652.                    just the active frame, hit c, which is the
  653.                    same as C if ScrnSec = 0 */
  654.         if(ScrnSec == 0) {
  655.                 /* this turns window overlap prevention off */
  656.             for(i = 0; i <= 4; i++)
  657.                 windowflag[i] = OFF;
  658.         }
  659.         clrWindow();
  660.         if(printer == 3)
  661.             bottomPrint();
  662.         SetCross(SMALLCROSS);
  663.         return(YES);
  664.     }
  665.  
  666.     if(kk == 'C') {    /* to clear screen and p[][], hit C; to clear
  667.                    just the active frame, hit c, which is the
  668.                    same as C if ScrnSec = 0 */
  669.         if(ScrnSec == 0) {
  670.                 /* this turns window overlap prevention off */
  671.             for(i = 0; i <= 4; i++)
  672.                 windowflag[i] = OFF;
  673.         }
  674.         stoplines();     /* for stopping drawing connected lines */
  675.         SignIsOn = 0;    /* sign about jump size */
  676.         IsCross0Set = NO;/* screen cross at y0 is not set */
  677.         IsCross1Set = NO;/* screen cross at y1 is not set */
  678.         scr_clr();    /* in desmets pcio.a */
  679.         clearp();
  680.         return(YES);
  681.     }
  682.  
  683.  
  684.     if(kk == 'e') {
  685.         if(step > -9999)
  686.             ODEcheck += 2;
  687.                 /* when dif eq is next called, it will call
  688.                    error_check,(in YTOOLS.C) and it will report
  689.                    error and then will reduce ODEcheck since it
  690.                    is greater than 1; */
  691.         return(YES);
  692.     }
  693.  
  694.     if(kk == 'E') {
  695.         if(step != -9999.) {
  696.             if(printer > 0 && ODEcheck == OFF) {
  697.                 PRINT
  698.                     "Differential equation errors will be printed every interate if interrupt \n");
  699.                 PRINT
  700.                     "key '3' is set; otherwise they will be computed but not printed.       \n");
  701.                 PRINT
  702.                     "Hit 'e' to get update on errors computed so far.\n");
  703.             }
  704.             ODEcheck = 1 - ODEcheck;
  705.             erase_line();
  706.             PRINT
  707.                 "CALCULATION of errors is now turned \n");
  708.             toggle(ODEcheck);/* prints " ON\n" or " OFF\n" */
  709.         }
  710.         return(YES);
  711.     }
  712.  
  713.     if(kk == 'i') {    /* re-initializes y[] to = y1[] */
  714.         interrupti();    /* in YCOMY.C;  re-initializes y[] to = y1[] */
  715.         return(YES);
  716.     }
  717.  
  718.     if(kk == 'I') {    /* turns on feature whereby each movement of
  719.                    the cursor is followed by "images" iterates
  720.                    of the map, plotting each dot along the way 
  721.                 */
  722.         images++;
  723.         plotImages();
  724.         scr_rowcol(1, 0);
  725.         if(printer > 0) {
  726.             erase_line();
  727.             PRINT
  728.                 "Number of images of small cross now = %d\n", images);
  729.             erase_line();
  730.             PRINT
  731.                 "This image feature is turned off by hitting 'i' or with command \"IMAGES\"\n"
  732.                 );
  733.         }
  734.         stoplines();    /* for stopping drawing connected lines */
  735.         return(YES);
  736.     }
  737.  
  738.     if(kk == 'j') {
  739.         jay();
  740.         return(YES);
  741.     }
  742.  
  743.     if(kk == 'k') {    /* When cross0flag = 1, program makes a
  744.                    temporary cross as each dot is plotted,
  745.                    erasing it when it is time to plot the next 
  746.                 */
  747.         turnoff(BIGCROSS);
  748.         cross0flag = 1 - cross0flag;
  749.         return(YES);
  750.     }
  751.  
  752.     if(kk == 'K') {    /* for making big cross permanent on both crt
  753.                    and core */
  754.     /* reverses a big cross permanent on both crt and core; temporarily we
  755.        turn off the other crosses */
  756.         plotSomething(0);
  757.                 /* sets plotX,plotY and plots a point but does
  758.                    not iterate */
  759.         if((temp = IsCross0Set) == YES)
  760.             turnoff(BIGCROSS);
  761.         if((temp1 = IsCross1Set) == YES)
  762.             turnoff(SMALLCROSS);
  763.         ResetScrnLineAtTop();
  764. #ifdef X11
  765.         CRTcrossON(plotX, plotY, CORECOLS / 50, (8 * COREROWS) / 36,
  766.             CORE);
  767. #else
  768.         if(printer > 1)
  769.             PRINT
  770.                 "Cross drawn at y[] on core;                     \r");
  771.         drawcross(plotX, plotY, CORECOLS / 50,(8 * COREROWS) / 36, CORE);
  772. #endif
  773.     /* permanent cross in core */
  774.         CRTcrossON(plotX, plotY,(3 * SCRNCROSSWIDTH) / 4,
  775.                 (3 * SCRNCROSSHEIGHT) / 4, color);
  776.     /* permanent midsize cross in CRT */
  777.         if(temp1 == YES)
  778.             SetCross(BIGCROSS);
  779.         if(temp == YES)
  780.             SetCross(SMALLCROSS);
  781.  
  782.         if(cycle == 0) {
  783.             return(RET);
  784.                 /* this allows us to hold down the 'K' key and
  785.                    get a series of crosses; I don't know every
  786.                    dot will then get a cross; that would depend
  787.                    on how fast the keyboard sends signals to
  788.                    the cpu. */
  789.         }
  790.         return(YES);
  791.     }
  792.     if(kk == 'l') {
  793.         ResetScrnLineAtTop();
  794.         if(num_lyap != -9999 && num_lyap != 0)
  795.             print_lyap(StOutPut);
  796.         else {
  797.             PRINT
  798.                 "Lyapunov exponents are not being calculated; see L: in parameter menu\r");
  799.         }
  800.         return(YES);
  801.     }
  802.  
  803.     if(kk == 'L') {
  804.         abcd();    /* in YCOMU.C */
  805.         return(YES);
  806.     }
  807.  
  808.     if(kk == 'm') {    /* transfer from one vec to another */
  809.         MoveVec();    /* after this call, ystore_in is the address of
  810.                    the changed vector */
  811.         SetCross(SMALLCROSS);
  812.         if(ystore_in == y && cycle > 0)
  813.             SetCross(BIGCROSS);
  814.         if(ystore_in == y) {
  815.             stoplines();  /* for stopping drawing connected lines */
  816.             plotSomething(0);/* sets plotX,plotY and plots */
  817.             start();
  818.             /* sets dot = 0 and lyap exponents are restarted */
  819.         }
  820.         return(YES);
  821.     }
  822.  
  823.     if(kk == 'O') {
  824.         stoplines();     /* for stopping drawing connected lines */
  825.         scr_rowcol(1, 0);
  826.         if(printer >= 2) {
  827.             erase_line();
  828.             PRINT
  829.                 "Hit 'I' to increase the number of images of the circle, 'i' to set it to 0\n"
  830.                 );
  831.             PRINT
  832.                 "Type #RA to chang radius of circle;    use arrow keys to move the center.\n");
  833.             PRINT
  834.                 "HIT SPACE BAR ONCE ONLY when you now want to terminate circle routine \n");
  835.             PRINT
  836.                 "####################### Hit r to refresh the screen. ########################"
  837.                 );
  838.         }
  839.         oldTaskFlag = taskFlag;
  840.         taskFlag = 100;
  841.         overflow = NO;
  842.         caseT();
  843.         if(overflow == YES)
  844.                 /* maybe == Yes from leaving box in caseT */
  845.             cycle = 2;
  846.         if(printer > 0)
  847.             PRINT
  848.                 "####################### Hit r to refresh the screen. ########################"
  849.                 );
  850.         taskFlag = oldTaskFlag;
  851.         kk = 'O';    /* note kk is static */
  852.         images = 0;
  853.         if(printer > 0)
  854.             PRINT
  855.                 "The number of \"IMAGES\" is set to 0  \n");
  856.         return(YES);
  857.     }
  858.  
  859.     if(kk == 'P') {    /* print copy of picture */
  860.         pprint(onprint);
  861. /*        kk = keycheck(); this lets you hit escape now */
  862.         beep();
  863.         return(YES);
  864.     }            /* note that keycheck()=='p' does not Interrupt
  865.                    printing p[][] */
  866.  
  867.     if(kk == 'q') {    /* print parameters etc on crt */
  868.         ResetScrnLineAtTop();
  869.         time1 = timeofday();
  870.         if(dot > 1 && dot > dotAtTime0
  871.                 && time1 >= time0
  872.                 && time0 != 0
  873.                 && time1 != 0 && printer > 0) {
  874.             doubleDot = (dot - dotAtTime0) /(time1 - time0);
  875.             if(printer > 0)
  876.                 PRINT
  877.                     "dots per second = %lf, seconds per dot = %lf      \n"
  878.                     ,doubleDot, 1 / doubleDot);
  879.         }
  880.         print_text(StOutPut);
  881.         if(IsCross1Set == YES && printer > 0) {
  882.             ss = ScrnSec;
  883.             erase_line();
  884.             PRINT
  885.                 "small cross at y1: X=%e Y=%e.Arrows change X by %lf\n",
  886.                 y[eqn0 + ssX_coord[ss]], y[eqn0 + ssY_coord[ss]]
  887.                 ,screen_fraction *(X_upper - X_lower));
  888.         }
  889.         for(i = 0; i < 10; i++)
  890.             if(message[i] != defaultMessage)
  891.                 PRINT message[i]);
  892.         return(YES);
  893.     }
  894.  
  895.     if(kk == 'Q') {
  896. #ifdef X11
  897.         printf("Color is not implemented yet\n");
  898. #else
  899.         setRGBColor();    /* will be asked for 3 integers */
  900. #endif
  901.         return(YES);
  902.     }
  903.  
  904.     if(kk == 'r') {    /* reboot screen to erase text */
  905.         stoplines();     /* for stopping drawing connected lines */
  906.         boot = 1;
  907.         boot_crt();
  908.         if(cycle > 0) {
  909.             SetCross(SMALLCROSS);
  910.             SetCross(BIGCROSS);
  911.         }
  912.         return(YES);
  913.     }
  914.  
  915.  
  916.     if(kk == 's') {    /* changes scale to new values,  resets
  917.                    temporary values to zero,  and moves y_init
  918.                    to the center of the new screen, and resets
  919.                    "diameters"  */
  920.         ResetScrnLineAtTop();
  921.         if(printer > 2)
  922.             PRINT
  923. "currently plotting in screen section number %d                \n"
  924.                 ,ScrnSec);
  925.         erase_line();
  926.         if(printer > 0) {
  927.             PRINT
  928. "Hit new sec. num.: F1=up.left; F2=up.right; F3=low.left; F4=low.rt.;F10=whole"
  929.                 );
  930.             PRINT "\r");
  931.         }
  932.  
  933. #ifdef X11
  934.         digit = awaitkey(0);
  935. #else
  936.         while((digit = keycheck()) == 0) {
  937.         };        /* keep trying until a character is entered */
  938. #endif
  939.     /* note that F1 = -59,...,F4= -62, so F1>F4  */
  940.  
  941.         if(digit == F1)
  942.             digit = '1';
  943.         if(digit == F2)
  944.             digit = '2';
  945.         if(digit == F3)
  946.             digit = '3';
  947.         if(digit == F4)
  948.             digit = '4';
  949.         if(digit == F10)
  950.             digit = '0';
  951.     /* so digit now has a value between 1 and 4 or = 10 */
  952.         if((digit >= '0' && digit <= '4')) 
  953.                 {
  954.             openWindow(digit-'0');
  955.         }
  956.         else {
  957.             erase_line();
  958.             PRINT "Section %d is not acceptible \r", digit);
  959.         }
  960.         return(YES);
  961.     }
  962.  
  963.     if(kk == 'u') {    /* reverses process s)cale */
  964.         unWindow();
  965.         return(YES);
  966.  
  967.     }
  968.     if(kk == 't') {    /* draws box with 4 to 9 tic marks on each side
  969.                    */
  970.         if(printer > 2) {
  971.             scr_rowcol(5, 0);
  972.             erase_line();
  973.             PRINT
  974.                 "Use Interrupt 'T' for small tic marks that are 5 times finer\n");
  975.         }
  976.         oldTicFlag = ticFlag;
  977.         ticFlag = ON;
  978.         draw_box();    /* calls PrintBoxCoordinates */
  979.         ticFlag = oldTicFlag;
  980.         return(YES);
  981.     }
  982.     if(kk == 'T') {    /* draws extra fine set of tic marks with 1/5
  983.                    resolution */
  984.         set_box();    /* should not be necessary */
  985.         if(set_box() != 0)
  986.             ticMarks(2);
  987.                 /* draws an extra set of fine tic marks */
  988.         else
  989.             scr_rowcol(3, 0), PRINT "BOX IS DEFECTIVE.\n");
  990.         return(YES);
  991.     }
  992.  
  993.     if(kk == 'v') {    /* 'v' inverts differential equations and
  994.                    henon: map        x -> rho - x*x + C1*y
  995.                    inverse     -y/C1 -> rho/(C1**2) -(-y/C1)**2
  996.                    +(-x/C1)/C1    */
  997.         invert();    /* in YCOMNDS1.C */
  998.         return(YES);
  999.     }
  1000.  
  1001.     if(kk == 'w') {    /* print position of small cross on screen */
  1002.         if(crossStatus == OFF) {
  1003.             crossStatus = ON;
  1004.             CrossPosition();
  1005.         }
  1006.     /* if crossStatus is ON, we print position of small cross */
  1007.         else {
  1008.             scr_rowcol(2, 28);
  1009.  
  1010.             crossStatus = OFF;
  1011.             if(printer > 0)
  1012.                 PRINT
  1013.                     "                                                  ");
  1014.             scr_rowcol(0, 0);
  1015.         }
  1016.         return(YES);
  1017.     }
  1018.  
  1019.     if(kk == 'W') {    /* print position of small cross on screen */
  1020.         scr_rowcol(3, 0);
  1021.         whenAndWhere();/* for interrupt W and command W */
  1022.         scr_rowcol(0, 0);
  1023.         return(YES);
  1024.     }
  1025.  
  1026.     if(kk == 'x') {    /* change X_lower to  y[eqn0+X_coord] */
  1027.         x_new_low = y[eqn0 + ssX_coord[ScrnSec]];
  1028.         return(YES);
  1029.     }
  1030.  
  1031.     if(kk == 'X') {    /* change X_upper to  y[eqn0+X_coord] */
  1032.         x_new_upp = y[eqn0 + ssX_coord[ScrnSec]];
  1033.         return(YES);
  1034.     }
  1035.  
  1036.     if(kk == 'y') {    /* change Y_lower to  y[eqn0+Y_coord] */
  1037.         y_new_low = y[eqn0 + ssY_coord[ScrnSec]];
  1038.         return(YES);
  1039.     }
  1040.  
  1041.     if(kk == 'Y') {    /* change Y_upper to  y[eqn0+Y_coord] */
  1042.         y_new_upp = y[eqn0 + ssY_coord[ScrnSec]];
  1043.         return(YES);
  1044.     }
  1045.  
  1046.     if(kk == 'z') {
  1047.     /* int printerStatus(num)  initializes the printer and returns status
  1048.        byte; meaning of bit: 7    printer busy 6    Acknowledge 5    out of
  1049.        paper 4    selected 3     I/O error 2,1    not used 0     time
  1050.        out         */
  1051.  
  1052.         PRINT "\n   printer status code 1: %d\n", printerStatus(1));
  1053.         PRINT "\n   printer status code 2: %d\n", printerStatus(2));
  1054.         PRINT
  1055.             "keyboard status %d;  \n", shift);
  1056.         return(YES);
  1057.     }
  1058. #ifdef MS
  1059.  
  1060.     if(kk == 'Z') {
  1061.         scr_rowcol(5, 5);
  1062.         if(++palette > 3)
  1063.             palette = 0;
  1064.         _selectpalette(palette);
  1065.         PRINT " scrncols = %d ,scrnrows = %d palette = %d   \n"
  1066.             ,scrncols, scrnrows, palette);
  1067.         return(YES);
  1068.     }
  1069. #endif
  1070.  
  1071.     if(kk == F1 || kk == F2 || kk == F3 || kk == F4 || kk == F10) 
  1072.     {
  1073.         if(kk == F1)
  1074.             ss = 1;
  1075.         else if(kk == F2)
  1076.             ss = 2;
  1077.         else if(kk == F3)
  1078.             ss = 3;
  1079.         else if(kk == F4)
  1080.             ss = 4;
  1081.         else if(kk == F10)
  1082.             ss = 0;
  1083.         switchToWindow(ss);
  1084.         return(YES);
  1085.     }
  1086. #ifdef MS
  1087.     if(kk == F5) {        /* reinitiallizes y = y1 and then does F7() */
  1088.         interrupti();    /* in YCOMY.C;  re-initializes y[] to = y1[] */
  1089.         f7();
  1090.         return(YES);
  1091.     }
  1092.     if(kk == F6) {
  1093.         interrupti();    /* re-initializes y[] to = y1[] */
  1094.         f8();
  1095.         return(YES);
  1096.     }
  1097.     if(kk == F7) {        /* decreases color number by 1 */
  1098.         f7();
  1099.         return(YES);
  1100.     }
  1101.     if(kk == F8) {        /* increases color number by 1 */
  1102.         f8();
  1103.         return(YES);
  1104.     }
  1105.     if(kk == F9) {
  1106.         f9();
  1107.         return(YES);
  1108.     }
  1109. #endif
  1110.     return(NO);        /* no interrupt for this kk */
  1111. }
  1112. #endif /* ifndef MAINFRAME */
  1113.  
  1114. start() {            /*  used in printing the vector lyapsum  */
  1115.     erase_line();
  1116.     dot = 0;        /* dot = 0 restarts lyap exponents */
  1117.     time0 = timeofday();
  1118.     dotAtTime0 = dot;
  1119. }
  1120.  
  1121.  
  1122. #ifdef MS
  1123.  
  1124. f7() /* decreases number of active color by 1 */
  1125. {
  1126. #ifndef MAINFRAME
  1127.     turnoff(BIGCROSS);
  1128.     turnoff(SMALLCROSS);
  1129. #endif /* if not def MAINFRAME */
  1130.     if(color > 0)
  1131.         color--;
  1132. #ifndef MAINFRAME
  1133.     _setcolor(color);
  1134.     scr_rowcol(2, 5);
  1135. #endif /* if not def MAINFRAME */
  1136.     if(SCREEN && printer >= 2)
  1137.         PRINT "new color = %d       \n", color);
  1138.     if (SCREEN && printer == 1)
  1139.             PRINT "  %d    \n",color);
  1140. #ifndef MAINFRAME
  1141.     SetCross(SMALLCROSS);
  1142.     turnoff(SMALLCROSS);
  1143.     SetCross(SMALLCROSS);
  1144. #endif /* if not def MAINFRAME */
  1145. }
  1146.  
  1147. f8() /* increases number of active color by 1 */
  1148. {
  1149. #ifndef MAINFRAME
  1150.     turnoff(BIGCROSS);
  1151.     turnoff(SMALLCROSS);
  1152. #endif /* if not def MAINFRAME */
  1153.     color++;
  1154. #ifndef MAINFRAME
  1155.     _setcolor(color);
  1156.     scr_rowcol(2, 5);
  1157. #endif /* if not def MAINFRAME */
  1158.     if(SCREEN && printer >= 1)
  1159.         PRINT "new color = %d       \n", color);
  1160. #ifndef MAINFRAME
  1161.     SetCross(SMALLCROSS);
  1162.     turnoff(SMALLCROSS);
  1163.     SetCross(SMALLCROSS);
  1164. #endif /* if not def MAINFRAME */
  1165. }
  1166.  
  1167. f9() {
  1168.     int     colorNum;
  1169.     double Entervalue();
  1170.  
  1171.     colorNum = color;
  1172.     colorNum = Entervalue((double)colorNum, CHECKSET);
  1173.     if(colorNum >= 0) {
  1174. #ifndef MAINFRAME
  1175.         turnoff(BIGCROSS);
  1176.         turnoff(SMALLCROSS);
  1177.         scr_rowcol(2, 5);
  1178. #endif /* if not def MAINFRAME */
  1179.         color = colorNum;
  1180.         if(SCREEN && printer >= 2)
  1181.             PRINT "new color = %d       \n", color);
  1182. #ifndef MAINFRAME
  1183.         _setcolor(color);
  1184.         SetCross(SMALLCROSS);
  1185.         turnoff(SMALLCROSS);
  1186.         SetCross(SMALLCROSS);
  1187. #endif /* if not def MAINFRAME */
  1188.     }
  1189. }
  1190. #endif /* MS */
  1191.  
  1192. openWindow(num)
  1193.     int num;
  1194. {
  1195.     if (num<0 || num >4)
  1196.         return;
  1197.  
  1198.     /* before switching sections, turn off crosses */
  1199.     stoplines();     /* for stopping drawing connected lines */
  1200.     UvsSflag = 0;    /* this says s was called more recently than u */
  1201.     turnoff(BIGCROSS);
  1202.     turnoff(SMALLCROSS);
  1203.     OldScrSec = ScrnSec;
  1204.     ScrnSec = num;
  1205.     if(ScrnSec != 0) {
  1206.         windowflag[0] = ON;
  1207.         windowflag[ScrnSec] = ON;
  1208.     }
  1209.     erase_line();
  1210.     X_coord = ssX_coord[ScrnSec] = ssX_coord[OldScrSec];
  1211.     Xplot[ScrnSec] = &y[X_coord];
  1212.     Y_coord = ssY_coord[ScrnSec] = ssY_coord[OldScrSec];
  1213.     Yplot[ScrnSec] = &y[Y_coord];
  1214.     if(printer > 0)
  1215.         PRINT
  1216.             "New section %d, coordinates x=%d, y=%d     \r", ScrnSec, X_coord, Y_coord);
  1217.  
  1218.     OldDiameters = diameters[ScrnSec];
  1219.     resetDiameters();
  1220.         /* in YPLOT.C; diameters must be reset before
  1221.            scale is changed */
  1222.  
  1223.     /* Recall: SetAndSave (new,current,old)  saves *current in *old
  1224.        and if new is set, it sets *current = *new; it then sets
  1225.        *new = *current double *new,*current,*old */
  1226.  
  1227.     SetAndSave(&x_new_low, &X_lower, &x_old_low);
  1228.     SetAndSave(&y_new_low, &Y_lower, &y_old_low);
  1229.     SetAndSave(&x_new_upp, &X_upper, &x_old_upp);
  1230.     SetAndSave(&y_new_upp, &Y_upper, &y_old_upp);
  1231.  
  1232.     ScreenConstants();
  1233.         /* defines ax,bx where x = 0,00,1,2 */
  1234.     clrWindow();
  1235.     draw_box();
  1236.  
  1237.     /* We used to center cross in window: y[eqn0+ssX_coord[ss]] =
  1238.       (X_lower + X_upper)/2; y[eqn0+ssY_coord[ss]] = (Y_lower +
  1239.        Y_upper)/2; 
  1240.     */
  1241.     SetCross(SMALLCROSS);
  1242. }
  1243.  
  1244. switchToWindow(ss)
  1245.     int ss;
  1246. {
  1247.     if (ss < 0 || ss > 4)
  1248.     {
  1249.         PRINT 
  1250. "No SUCH WINDOW EXISTS \n");
  1251.         return;
  1252.     }
  1253.  
  1254.     stoplines();     /* for stopping drawing connected lines */
  1255.     if(allSSFlag == YES) 
  1256.     {/* now plot in only one frame */
  1257.         allSSFlag = NO;
  1258.         if(X_coord >= 0 && Y_coord >= 0 && X_coord != Y_coord) 
  1259.                 taskFlag = PLOTXY;
  1260.         else
  1261.             PRINT
  1262. "To resume plotting in just that window, return to menu and CONTinue process\n"
  1263.                 );
  1264.     }/* if allSSFlag */
  1265.     /* If either cross is on then turn it off */
  1266.     turnoff(BIGCROSS);
  1267.     turnoff(SMALLCROSS);
  1268.  
  1269.     if(xScrPix[ss] == -9999)
  1270.         PRINT
  1271. "Not acceptable: THIS WINDOW IS NOT OPEN; first set scale using 's'      \n");
  1272.  
  1273.     else 
  1274.     {
  1275.         ScrnSec = ss;
  1276.         X_lower = X_Lo[ss];
  1277.         X_upper = X_Up[ss];
  1278.         Y_upper = Y_Up[ss];
  1279.         Y_lower = Y_Lo[ss];
  1280.         ScreenConstants();
  1281.         if(ss != 0) 
  1282.         {
  1283.             windowflag[0] = ON;
  1284.             if(windowflag[ss] == OFF) 
  1285.             {
  1286.                 clrWindow();
  1287.                 draw_box();
  1288.             }
  1289.             windowflag[ss] = ON;
  1290.         }/* end if */
  1291.         SetCross(SMALLCROSS);
  1292.         ResetScrnLineAtTop();
  1293.         if(printer > 2)
  1294.             PRINT
  1295. "currently plotting in screen section number %d                \n"
  1296.                     ,ScrnSec);
  1297.     }/* end else */
  1298. }
  1299.  
  1300. unWindow()/* called by interrpt 'u': undoes 's' more or less */
  1301. {
  1302.     stoplines();     /* for stopping drawing connected lines */
  1303.     if(UvsSflag == 1) {
  1304.             /* this means 'u' is being used as a toggle */
  1305.     /* the following 4 resets the box to be the old box */
  1306.         SwitchD(&x_old_low, &x_new_low);
  1307.         SwitchD(&y_old_low, &y_new_low);
  1308.         SwitchD(&x_old_upp, &x_new_upp);
  1309.         SwitchD(&y_old_upp, &y_new_upp);
  1310.     }
  1311.     UvsSflag = 1;    /* this says 'u' was called more recently than
  1312.                's'; */
  1313.     turnoff(BIGCROSS);
  1314.     turnoff(SMALLCROSS);
  1315.     if(OldDiameters == -9999.) {
  1316.         erase_line();
  1317.         PRINT
  1318.             "Cannot unscale ('u') because no old scale is set\n");
  1319.         return(RET);
  1320.     }
  1321.     SwitchI(&ScrnSec, &OldScrSec);
  1322.     SwitchD(&diameters[ScrnSec], &OldDiameters);
  1323.     X_coord = ssX_coord[ScrnSec] = ssX_coord[OldScrSec];
  1324.     Xplot[ScrnSec] = &y[X_coord];
  1325.     Y_coord = ssY_coord[ScrnSec] = ssY_coord[OldScrSec];
  1326.     Yplot[ScrnSec] = &y[Y_coord];
  1327.  
  1328. /* Recall: SetAndSave(new,current,old)  saves *current in *old and if
  1329.    new is set, it sets *current = *new; it then sets *new = *current
  1330.    double *new,*current,*old */
  1331. /* without the following 4 lines, the box doesn't change */
  1332.     SwitchD(&x_old_low, &x_new_low);
  1333.     SwitchD(&y_old_low, &y_new_low);
  1334.     SwitchD(&x_old_upp, &x_new_upp);
  1335.     SwitchD(&y_old_upp, &y_new_upp);
  1336.  
  1337.     SetAndSave(&x_new_low, &X_lower, &x_old_low);
  1338.             /* same as in 's' */
  1339.     SetAndSave(&y_new_low, &Y_lower, &y_old_low);
  1340.     SetAndSave(&x_new_upp, &X_upper, &x_old_upp);
  1341.     SetAndSave(&y_new_upp, &Y_upper, &y_old_upp);
  1342.     ScreenConstants();/* defines ax,bx where x = 0,00,1,2 */
  1343.  
  1344.     /* the following 4 resets the box to be the old box */
  1345.     SwitchD(&x_old_low, &x_new_low);
  1346.     SwitchD(&y_old_low, &y_new_low);
  1347.     SwitchD(&x_old_upp, &x_new_upp);
  1348.     SwitchD(&y_old_upp, &y_new_upp);
  1349.  
  1350.     if(ScrnSec == 0)
  1351.         boot_crt();/* this clears p and the screen */
  1352.     SetCross(SMALLCROSS);
  1353. }
  1354.  
  1355.  
  1356.